package com.example.guiguiapplicatio.fragment.followup;

import android.os.Bundle;

import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;


import com.example.guiguiapplicatio.R;
import com.example.guiguiapplicatio.Response.Record;
import com.example.guiguiapplicatio.databinding.FragmentClassifyBinding;
import com.example.guiguiapplicatio.fragment.followup.adapter.ClassifyFragmentAdapter;

import com.google.android.material.bottomnavigation.BottomNavigationView;

import java.util.ArrayList;

import java.util.List;


public class ClassifyFragment extends Fragment {

    private FragmentClassifyBinding binding;
    private ClassifyFragmentAdapter adapter;
    private List<String> mClassifications=new ArrayList<>();
    private Record record;
    private Boolean IS_WITHOUT_NET=false;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);


        iniData();
    }
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        binding= FragmentClassifyBinding.inflate(inflater,container,false);

        record= (Record) getArguments().getSerializable("Record");
        IS_WITHOUT_NET= (Boolean) getArguments().getSerializable("IS_WITHOUT_NET");

        adapter=new ClassifyFragmentAdapter(mClassifications,record,IS_WITHOUT_NET);
        binding.recy.setLayoutManager(new StaggeredGridLayoutManager(2,StaggeredGridLayoutManager.VERTICAL));
        binding.recy.setAdapter(adapter);

        binding.back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                getActivity().onBackPressed();
            }
        });


        return binding.getRoot();
    }

    private void iniData() {

        mClassifications.add("新生儿");
        mClassifications.add("高血压");
        mClassifications.add("老年人");
        mClassifications.add("肺结核");
        mClassifications.add("严重精神障碍");
        mClassifications.add("类风湿关节炎");
        mClassifications.add("脑血管疾病后遗症");


    }

    @Override
    public void onResume() {
        BottomNavigationView bottomNavigationView=requireActivity().findViewById(R.id.nav_view);
        bottomNavigationView.setVisibility(View.INVISIBLE);
        //这两行代码设置隐藏底部导航栏，若要显示啧修改INVISIBLE为Visible（可见）
        super.onResume();
    }
}